/**
* @class FB_Person_GUI_menubar
* @author  Alexei Bratuhin
* @description menubar for tha application. Provides graphical interface for login into Facebook together with some help and about functionality
**/

package org.abratuhi.fbpersona.src.gui;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;

import org.abratuhi.fbpersona.src.model.FB_Persona_Client;

@SuppressWarnings("serial")
public class FB_Persona_GUI_menubar extends JMenuBar implements ActionListener{
	
	FB_Persona_Client c;
	FB_Persona_GUI root;
	
	JMenu m_file = new JMenu("File");
	JMenu m_net = new JMenu("Network");
	JMenu m_help = new JMenu("Help");
	
	JMenuItem mi_exit = new JMenuItem("Exit");
	JMenuItem mi_login = new JMenuItem("Login");
	JMenuItem mi_logout = new JMenuItem("Logout");
	JMenuItem mi_about = new JMenuItem("About");
	JMenuItem mi_help = new JMenuItem("Help");
	
	public FB_Persona_GUI_menubar(FB_Persona_GUI r, FB_Persona_Client c){
		super();
		this.root = r;
		this.c = c;
		mi_exit.addActionListener(this);
		mi_login.addActionListener(this);
		mi_logout.addActionListener(this);
		mi_about.addActionListener(this);
		mi_help.addActionListener(this);
		m_file.add(mi_exit);
		m_net.add(mi_login);
		m_net.add(mi_logout);
		m_help.add(mi_about);
		m_help.add(mi_help);
		add(m_file);
		add(m_net);
		add(m_help);
	}

	public void actionPerformed(ActionEvent e) {
		if(e.getActionCommand().equals(mi_exit.getActionCommand())){
			root.exit();
		}
		if(e.getActionCommand().equals(mi_login.getActionCommand())){
			c.login(root);
		}
		if(e.getActionCommand().equals(mi_logout.getActionCommand())){
	
		}
		if(e.getActionCommand().equals(mi_about.getActionCommand())){
			JOptionPane.showMessageDialog(root, "Persona Search Tool\n" +
												"v 1.0\nbased on Facebook API and data\n" +
												"author: Alexei Bratuhin", "About", JOptionPane.INFORMATION_MESSAGE);
		}
		if(e.getActionCommand().equals(mi_help.getActionCommand())){
			JOptionPane.showMessageDialog(root, "area:           desired field of activity\n" +
												"it experience:  novice/medium/expert\n" +
												"tags:           comma-separated, comma-ending list of tags", "Help", JOptionPane.INFORMATION_MESSAGE);
		}
	}

}
